$(function(){
        /**
         *获取url中指定字符变量的值
         */
        function getQueryString(name){  
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");  
            var r =location.search.substr(1).match(reg);  
            if (r != null){
                return unescape(r[2]);
            }else{
                return null;
            }      
        }
        var salesManId=(getQueryString("salesManId")!=null)?getQueryString("salesManId"):"";
        var userId=(getQueryString("userId")!=null)?getQueryString("userId"):"";
        console.log(userId+"----");
        var url=SYS_GLOBAL_CONFIG.reqUrl,
            async=true,
            type="post";
        var JsonData={
            "code": "businessFeeSeller",
            "version": "1.0",
            "data": {
                "salesManId":salesManId,
                "currentPage": 1,
                "showCount": 10
            }
        };
        var JsonDataIncome={
            "code": "myIncome",
            "version": "1.0",
            "data": {
                "salesManId":salesManId,
                "userId":parseInt(userId),
                "agentId": ""
            }
        };
        var JsonDataUser={
            "code": "getUserNameImg",
            "version": "1.0",
            "data": {
                "salesManId":salesManId
            }
        };
        var requestData=JSON.stringify(JsonData); 
        var requestDataUser=JSON.stringify(JsonDataUser);
        var requestDataIncome=JSON.stringify(JsonDataIncome); 
        getData(url,requestData,handdle_func_succ,handdle_func_err,async,type);  
    //获取数据
        getData(url,requestDataUser,handdle_func_user_succ,handdle_func_user_err,async,type);  
            getData(url,requestDataIncome,handdle_func_income_succ,handdle_func_income_err,async,type); 
        //调用公共的ajax
        function getData(url,requestData,handdle_func_succ,handdle_func_err,async,type){
            $.ajax({
                url:url,
                type:type,
                datatype:"json",       
                async:async,
                contentType:"application/json",
                data:requestData,
                success:function(data){
                    handdle_func_succ(data);
                },
                error:function(msg){
                    handdle_func_err(msg);
                }   
            });        
        }
        
        /**
         *获取用户个人的收入以及推广的商家信息
         */
        function handdle_func_succ(data){
            var datas=data.data.datas;
            var dataStr="";
            var len=datas.length;
            var bord="";
            if(len>0){
                for(var i=0;i<len;i++){
                    if((i+1)==len){
                        bord="noBorder";
                    }else{
                        bord="hasBorder2";
                    }
                    dataStr+='<div class="shops-detail '+bord+'"><div class="l shops-det-img"><img src="'+datas[i].logoImgIdFullPath+'" alt=""></div><div class="l shops-det-cont"><p class="big-h"><span>'+datas[i].shopName+'</span></p><p class="small-h"><span class="">付费:'+datas[i].allFee/100+'元</span></p></div><div class="clears"></div></div>';
                }
                $(".shops").html(dataStr);
            }
            
        }
        function handdle_func_err(msg){
            console.log(msg);
        }
        /**
         *获取用户头像跟用户名以及是否为vip相关信息
         **/
        function handdle_func_user_succ(data){
            var dataUser=data.data.user;
            var userImg="";
//            var isVip=(==1)?true:false;
            var vip=(dataUser.isVip==1)?true:false;
            console.log(vip+"---"+dataUser.isVip);
            if(vip){//是否为vip
                $(".user-info .user-info-name ").find("img").attr("src","../images/personService.png");
            }else{
                $(".user-info .user-info-name ").find("img").css("display","none");
            }
            if(dataUser.agentId!="null"&&dataUser.agentId!=null){
                $(".areaPerson").html("[区域合伙人]");  
            }else{
                $(".areaPerson").html("");
            }
            if(dataUser.path!="null"&&dataUser.path!=null){
                userImg=dataUser.path;
            }else{
                userImg="../images/default.jpg";
            }
            $(".user-Img").find("img").attr("src",userImg);
            $("#username").html(dataUser.userName);
            
            $(".tel-message").find(".tell-span").attr("href", "tel:" + dataUser.phoneNO);//打电话
             $(".tel-message").find(".mess-span").attr("href", "sms:" + dataUser.phoneNO);//发消息
        }
        function handdle_func_user_err(msg){
            console.log(msg);
        }
        function handdle_func_income_succ(data){
            $("#income-count-shop").html(data.data.sellerCount);
            $("#income-count-pay").html(data.data.sellerPayCount);
            $("#income-count-all").html(data.data.allIncome/100);
        }
        function handdle_func_income_err(msg){
            console.log(msg);
        }
    });